package com.hh.entity.vo;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * com.hh.entity.vo
 *
 * @author hanhui
 * @version 1.0
 * @since 2025/8/19 21:25
 **/
@Getter
@Data
public class TagCount {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    private List<String> tagName;
    private Integer count;

    // 构造函数、getter和setter
    public TagCount(List<String> tagName, Integer count) {
        this.tagName = tagName;
        this.count = count;
    }

    public TagCount(String tagName, Integer count) {
        try {
            this.tagName = objectMapper.readValue(tagName, new TypeReference<List<String>>(){});
        } catch (JsonProcessingException e) {
            this.tagName = new ArrayList<>();
            this.tagName.add(tagName);
        }
        this.count = count;
    }

}
